﻿using Airborne.ScrumPoker.Module.TeamFoundation.Controllers;
using Airborne.ScrumPoker.Module.TeamFoundation.Tests.Mocks;
using Airborne.ScrumPoker.Module.TeamFoundation.Views;
using Airborne.ScrumPoker.Module.Tests;
using Microsoft.Practices.Unity;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Airborne.ScrumPoker.Module.Events;
using Microsoft.Practices.Composite.Events;

namespace Airborne.ScrumPoker.Module.TeamFoundation.Tests.Controllers
{
    [TestClass]
    public class WorkItemControllerTestFixture
    {
        [TestMethod]
        public void WorkItemControllerTest()
        {
            IUnityContainer container = new UnityContainer();
            MockRegionManager regionManager = new MockRegionManager();
            regionManager.Regions.Add( RegionNames.TeamFoundation, new MockRegion());
            MockWorkItemView mockView = new MockWorkItemView();
            MockEventAggregator eventAggregator = new MockEventAggregator();

            eventAggregator.AddMapping<GenericEvent<int>>(new GenericEvent<int>());
            
            container.RegisterInstance<IWorkItemSelectView>(mockView, new ExternallyControlledLifetimeManager());

            WorkItemController controller = new WorkItemController(regionManager, eventAggregator, container, null);
            controller.Run();

          

            MockRegion region = regionManager.Regions[RegionNames.TeamFoundation] as MockRegion;
            Assert.AreEqual(1, region.AddedViews.Count);
            Assert.AreEqual(mockView, region.AddedViews[0]);

        }
    }

    
}
